<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class Denturalia extends CI_Controller {

    function __construct(){
        parent::__construct();
        //$this->lang->load('ini_'.$this->config->item('language'), $this->config->item('language'));
        $this->template->write_view('footer', 'footer');
        $this->template->write_view('header', 'header');
        $this->template->write_view('_scripts', 'js', array('ruta' => site_url().'public/'.$this->template->getActiveTemplate()));
        $this->template->write_view('_styles', 'css', array('ruta' => site_url().'public/'.$this->template->getActiveTemplate()));
    }

    function process($metodo = '', $request = null){
        $this->load->helper('url');
        $server_url = 'http://127.0.0.1/gestorweb/';

        $this->load->library('xmlrpc');
        $this->xmlrpc->server($server_url, 80);
        $this->xmlrpc->method($metodo);
        $this->xmlrpc->set_debug($this->config->item('debug_xmlrpc'));

        $this->xmlrpc->request($request);

        if (!$this->xmlrpc->send_request()) {
            log_message('error', 'Error en la recepcion de peticion: '.$this->xmlrpc->display_error());
            return null;
        } else {
            return $this->xmlrpc->display_response();
        }
    }


    function index() {
        $peticion = $this->select('1');
        $response = $this->process('con.sel', $peticion);
        if($response != null){
            for($x = 0; $x < count($response); $x++){
                $data[$response[$x]['con_etiqueta']] = $response[$x]['con_texto'];
            }
        }
        $data['ruta'] = site_url().'public/'.$this->template->getActiveTemplate();
        $this->template->write_view('content', 'content/index', $data);
        $this->template->render();
    }

    function select($ids = ''){
        $request = array(
            array(
                // Param 0
                array(
                    'library' => 'usuario',
                    'method' => 'add'
                ),
                'struct'
            ),
            array(
                // Param 1
                array(
                    'where' => 'con_idpagina in ('.$ids.')'
                ),
                'struct'
            )
        );
        return $request;
    }
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */